//
//  Rank_PeopleInfo_Botton.m
//  YLProject
//
//  Created by 张伯林 on 2018/2/2.
//  Copyright © 2018年 WY. All rights reserved.
//

#import "Rank_PeopleInfo_Botton.h"

@implementation Rank_PeopleInfo_Botton
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}
-(void)createView{
    [self addSubview:self.touchButton];
    [self addSubview:self.imageView];
    [self addSubview:self.titleLabel];
}
#pragma mark ----- 懒加载
-(UIImageView *)imageView{
    if(!_imageView){
        _imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.frame.size.width / 2 - 24 * YL_KEY, self.height / 2 - 8 * YL_KEY, 16 * YL_KEY, 16 * YL_KEY)];
//        _imageView.image = [UIImage imageNamed:@"排行_highlight"];
        _imageView.backgroundColor = [UIColor purpleColor];
    }
    return _imageView;
}
-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.frame.size.width / 2 - 3, self.height / 2 - 8 * YL_KEY, self.width / 2, 16 * YL_KEY)];
        _titleLabel.font = YLFont(13);
        _titleLabel.textColor = [UIColor whiteColor];
    }
    return _titleLabel;
}
-(UIButton *)touchButton{
    if(!_touchButton){
        _touchButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _touchButton.frame = CGRectMake(0,0,self.width,self.height);
        [_touchButton addTarget:self action:[self selectorBlock:^(id weak, id arg) {
            if(self.block) self.block();
        }] forControlEvents:UIControlEventTouchUpInside];
    }
    return _touchButton;
}
-(void)setText:(NSString *)text imageName:(NSString *)imageName{
    self.titleLabel.text = text;
    [self.titleLabel sizeToFit];
    self.imageView.image = [UIImage imageNamed:@""];
}
@end
